package com.fejal.dao;


import java.util.List;


import com.fejal.bean.Curso;
import com.fejal.bean.TurmaOfertaDisciplina;

public class TurmaOfertaDisciplinaDAOHibernate implements TurmaOfertaDisciplinaDAO {
	HibernateDAOFactory hibernateDAOFactory = null;
	HibernateDAO<TurmaOfertaDisciplina> hibernateDAO = null;

	public TurmaOfertaDisciplinaDAOHibernate() {
		hibernateDAOFactory = new HibernateDAOFactory();
		hibernateDAO = hibernateDAOFactory.getTurmaOfertaDisciplinaDao();
	}
	@Override
	public TurmaOfertaDisciplina getTurmaOfertaDisciplina(int codigoTurmaOfertaDisciplina) {
		TurmaOfertaDisciplina turmaOfertaDisciplina = hibernateDAO.get(codigoTurmaOfertaDisciplina);
		return turmaOfertaDisciplina;
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<Curso> getCursosCorrelatas(String identificador) {
	
		String sql = " Select turmaOfertaDisciplina.turmaOferta.turma.curso as curso "+
					 " From TurmaOfertaDisciplina as turmaOfertaDisciplina "+
					 " where turmaOfertaDisciplina.disciplina.identificador = '"+identificador+"'"+
					 " Order by turmaOfertaDisciplina.turmaOferta.turma.curso.codigoCurso "; 
		
		List<Curso> lista = hibernateDAO.getSession().createQuery(sql).list();
		return lista;
	}




}
